Imports Microsoft.VisualBasic

Public Class VersionManager
    Public Locked As Boolean
    Public Generated As Boolean

    Public Sub New(ByVal YYMM As String, ByVal Signature As String)
        Me.GetVersionData(YYMM, Signature, "")
    End Sub

    Public Sub New(ByVal YYMM As String, ByVal Signature As String, ByVal HeaderTB As String)
        Me.GetVersionData(YYMM, Signature, HeaderTB)
    End Sub

    Public Sub GetVersionData(ByVal YYMM As String, ByVal Signature As String)
        Me.GetVersionData(YYMM, Signature, "")
    End Sub

    Public Sub GetVersionData(ByVal YYMM As String, ByVal Signature As String, ByVal HeaderTB As String)
        Dim dat As New clsData
        Dim sql As New StringBuilder
        Dim dt As DataTable

        sql.AppendFormat(" Select IsNull(Locked,'N') as Locked,IsNull(Generated,'N') as Generated from VersionControl ")
        sql.AppendFormat(" Where 1=1 ")
        sql.AppendFormat(" and HeaderTB='{0}' ", HeaderTB)
        sql.AppendFormat(" and YYMM='{0}' ", YYMM)
        sql.AppendFormat(" and Signature='{0}' ", Signature)

        dt = dat.GetData(sql.ToString())

        If dt.Rows.Count = 0 Then
            Me.Locked = False
            Me.Generated = False
        Else
            Me.Locked = IIf(dt.Rows(0)("Locked").ToString() = "Y", True, False)
            Me.Generated = IIf(dt.Rows(0)("Generated").ToString() = "Y", True, False)
        End If
    End Sub
End Class
